package com.md.model.word;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument;

import java.io.IOException;
import java.util.List;

/**
 * @author 刘骄阳
 * 2024-06-14 14:44
 */
@Slf4j
public class ThemeDocumentStyle extends BaseDocumentStyle {
  private final List<ThemeDocument> themeDocuments;

  public ThemeDocumentStyle() {
    super(XWPFRelation.THEME);
    themeDocuments = Lists.newArrayList();
  }

  public ThemeDocumentStyle(final XWPFDocument document) {
    super(XWPFRelation.THEME);
    themeDocuments = Lists.newArrayList();
    initStyleList(document);
  }

  public List<ThemeDocument> getThemeDocuments() {
    return themeDocuments;
  }

  @Override
  protected void setPartList(final POIXMLDocumentPart documentPart) throws IOException, XmlException {
    themeDocuments.add(ThemeDocument.Factory.parse(documentPart.getPackagePart().getInputStream()));
  }
}
